﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using ClassLibrary.DAO;
using ClassLibrary.Entity;

public partial class Wedding_MasterPage_Wedding : System.Web.UI.MasterPage
{
    TblCustomersDAO customerDAO = new TblCustomersDAO(Global.CONNECTION_STRING);
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session[Global.SESSION_LOGGED_USER] == null)
            {
                lbhello.Visible = true;
                panel2.Visible = true;
                panel1.Visible = false;

            }
            else
            {
                lb_ten.Text = ((TblCustomers)Session[Global.SESSION_LOGGED_USER]).FName + ' ' + ((TblCustomers)Session[Global.SESSION_LOGGED_USER]).LName;
                lbhello.Visible = false;
                panel2.Visible = false;
                panel1.Visible = true;
                btThoat.Visible = true;
            }
        }
    }
    protected void btThoat_Click(object sender, EventArgs e)
    {
        Session[Global.SESSION_LOGGED_USER] = null;
        Response.Redirect("~/Wedding/Default.aspx");
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        bool bFlag = false;
        try
        {
            TblCustomers userAccount = customerDAO.GetUser(txt_email.Text.Trim());
            if (userAccount != null && userAccount.CusID != 0)
            {
                Session[Global.SESSION_LOGGED_USER] = userAccount;
                bFlag = true;
            }
            else
            {
                ScriptManager.RegisterStartupScript(ImageButton1, ImageButton1.GetType(), "alert", "alert('Email Not Found !');", true);
            }
        }
        catch (Exception ex)
        {
            Session[Global.SESSION_ERROR] = ex;
            Response.Redirect(Global.ERROR_PAGE, true);
        }
        if (bFlag)
        {
            //ScriptManager.RegisterStartupScript(cmdLogin, cmdLogin.GetType(), "ScriptLoginSuccess", "UpdateParentsLogin();", true);
            Response.Redirect(string.Format("~/Wedding/Default.aspx"), true);
        }
    }
}
